package com.baize.baizeapp.test.video
import com.baize.baizeapp.App

object VideoPlayerManager {

    val hsVideoView: HeiShiTTVideo by lazy {
        HeiShiTTVideo(App.getInstance())
    }

    private var currAttachPreView: HSPreVideoView? = null

    fun attachToPreVideo(preVideo: HSPreVideoView) {
        removeAttach()
//        hsVideoView = HeiShiTTVideo(contexts)
        currAttachPreView = preVideo
        preVideo.attachVideo(hsVideoView)
        hsVideoView.setUrl(preVideo.videoUrl)
        hsVideoView.play()
    }

    fun removeAttach() {
        hsVideoView.release()
        currAttachPreView?.removeVideo(hsVideoView)
        currAttachPreView = null
    }

    fun isAttach() : Boolean{
        return currAttachPreView != null && currAttachPreView?.isAttachedToWindow ?: false
    }
}